import math
class Solution(object):
    def numberOfRounds(self, loginTime, logoutTime):
        def convert(time):
            t = time.split(':')
            return [int(t[0]), int(t[1])]

        t1 = convert(loginTime)
        t2 = convert(logoutTime)
        if t1 > t2:
            t2[0] += 24
        ans = 0
        if t2[0] > t1[0]:
            ans += (t2[0] - t1[0] - 1) * 4
            if t1[1] <= 0:
                ans += 4
            else:
                if t1[1] <= 15:
                    ans += 3
                else:
                    if t1[1] <= 30:
                        ans += 2
                    else:
                        if t1[1] <= 45:
                            ans += 1
            ans += t2[1] // 15
        else:
            ans = max(t2[1] // 15 - math.ceil(t1[1] / 15), 0)
        return ans

